/*
* This file is a part of the open-eBackup project.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright (c) [2024] Huawei Technologies Co.,Ltd.
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*/
#include "common/TimeOutTest.h"

static mp_void StubCLoggerLog(mp_void){
    return;
}

TEST_F(TimeOutTest, CTimeOut)
{
    stub.set(&CLogger::Log, StubCLoggerLog);
    mp_int32 iRet;
    CTimeOut work(0);
    iRet = work.Remaining();
    EXPECT_EQ(iRet, 0);

    CTimeOut work1(TIMEOUT_INFINITE);
    iRet = work1.Remaining();
    EXPECT_EQ(iRet, TIMEOUT_INFINITE);

    CTimeOut work2(1);
    DoSleep(2000);
    iRet = work2.Remaining();
    EXPECT_EQ(iRet, 0);

    CTimeOut work3(48);
    iRet = work3.Remaining();
    EXPECT_EQ(iRet, 48);
}
